/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 * 这个才是正版之前那个是狗屎
 * Change Logs:
 * Date           Author       Notes
 * 2025-08-29     RT-Thread    first version
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <drv_common.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include "stm32f1xx_hal.h"
void HAL_DebugPort_Config(void)
{
    // 1. 使能AFIO/SYSCFG时钟（根据芯片系列选择）
    // STM32F1系列：使能AFIO时钟
    __HAL_RCC_AFIO_CLK_ENABLE();

    // 2. 禁用SWJ调试接口（JTAG+SW-DP）)
    // F1系列：操作AFIO_MAPR寄存器
    AFIO->MAPR &= ~AFIO_MAPR_SWJ_CFG_Msk;          // 清除原有配置
     AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;   // 禁用JTAG，保留SWD
}

int main(void)
{
    int count = 1;
    rt_pin_mode(GET_PIN(C, 13), PIN_MODE_OUTPUT);
    HAL_DebugPort_Config();
    while (1)
    {
        rt_pin_write(GET_PIN(C, 13), PIN_HIGH); // 初始状态：灭
        rt_thread_mdelay(2000);
        rt_pin_write(GET_PIN(C, 13), !PIN_HIGH); // 初始状态：灭

        rt_thread_mdelay(2000);


    }
    return RT_EOK;
}
